﻿import QtQuick 2.0

Rectangle {
    id: nexeLevelScreen
    scale: 0

    color: Qt.rgba(216/255, 148/255, 49/255, 1)
    border.color: Qt.rgba(120/255, 70/255, 0, 1)
    border.width: 5

    width: 700
    height: 300

    Keys.onBackPressed: {
        return
    }

    Behavior on scale {
        SpringAnimation{
            damping: 0.9
            spring: 5
        }
    }

    signal clickButtons(var value)

    onClickButtons: {
        if(value == 1){
            restart()
        }
        else if(value == 2){
            nexeLevelScreen.scale = 0

            levelScreen.scale = 1
            levelScreen.focus = true
        }
        else if(value == 3){
            next()
        }
    }

    function next(){
        if(fireBall){
            fireBall.destroy()

        }
        fireItem.create()
        canPress = true

        nexeLevelScreen.scale = 0
        score = 0

        level.ready(level.currentLevel+1)

        bStartGame = true

        rectBgMain.focus = true
    }

    function restart(){
        //重新开始
        if(fireBall){
            fireBall.destroy()

        }
        else{

        }
        fireItem.create()
        canPress = true

        nexeLevelScreen.scale = 0
        score = 0

        level.ready(level.currentLevel)

        bStartGame = true

        rectBgMain.focus = true
    }

    Row{
        anchors.centerIn: parent
        spacing: 10
        width: img.width*3+spacing*2
        height: img.height

        Image{
            id: img
            source: "qrc:/img/img/restart.png"
            MouseArea{
                anchors.fill: parent
                onClicked: clickButtons(1)
            }
        }
        Image{
            source: "qrc:/img/img/level.png"
            MouseArea{
                anchors.fill: parent
                onClicked: clickButtons(2)
            }
        }
        Image{
            source: "qrc:/img/img/next.png"
            MouseArea{
                anchors.fill: parent
                onClicked: clickButtons(3)
            }
        }

    }
}

